const {Fenlei} = require("./model.js");

const FenleiDao = {
	// 保存
	save(Fenleiinfo) {
		const fenlei = new Fenlei(Fenleiinfo);
		return fenlei.save(); // 返回Promise对象
    },
    //记录总条数
    count(){
        return Fenlei.find().count();
    },
    findByPage(page){
        //假设每页面十条数据
        const pageSize = 10;
        return Fenlei.find().skip((page-1)*pageSize).limit(pageSize);
    },




	// 查找
	find() {
	
	},
	update(updateData) {
        return Fenlei.findByIdAndUpdate(updateData.id,{$set:updateData})
    },
	delete(removed) {
        return Fenlei.remove(removed);
    }
};

module.exports = FenleiDao;